<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title> 角色分配 </title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="${ctx!}/assets/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="${ctx!}/assets/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="${ctx!}/assets/css/animate.css" rel="stylesheet">
    <link href="${ctx!}/assets/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>说明</h5>
                </div>
                <div class="ibox-content">
                    <p>为【${user.nickName}】分配角色</p>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>选择角色</h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal" id="frm" method="post" action="">
                        <div class="form-group">
                            <#list roles as role>
                                <div class="col-sm-12">
                                    <div class="checkbox i-checks">
                                        <label>
                                            <#if roleIds?seq_contains(role.id)>
                                                <input type="checkbox" value="${role.id}" name="roleIds" checked="checked"> <i></i> ${role.name}
                                            <#else>
                                                <input type="checkbox" value="${role.id}" name="roleIds"> <i></i> ${role.name}
                                            </#if>
                                        </label>
                                    </div>
                                </div>
                            </#list>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button class="btn btn-primary" type="submit">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>

</div>


<!-- 全局js -->
<script src="${ctx!}/assets/js/jquery.min.js?v=2.1.4"></script>
<script src="${ctx!}/assets/js/bootstrap.min.js?v=3.3.6"></script>

<!-- 自定义js -->
<script src="${ctx!}/assets/js/content.js?v=1.0.0"></script>

<!-- jQuery Validation plugin javascript-->
<script src="${ctx!}/assets/js/plugins/validate/jquery.validate.min.js"></script>
<script src="${ctx!}/assets/js/plugins/validate/messages_zh.min.js"></script>
<script src="${ctx!}/assets/js/plugins/layer/layer.min.js"></script>
<script src="${ctx!}/assets/js/plugins/layer/laydate/laydate.js"></script>
<script type="text/javascript">
    //文档初始化
    $(document).ready(function () {
        //表单提交验证
        $('#frm').validate({
            rules: {

            },
            messages: {

            },
            submitHandler:function(form) { //提交表单
                $.ajax({
                    type: 'post',
                    dataType: 'json',
                    url: '${ctx!}/admin/user/grant/' + ${user.id}, //给用户分配角色
                    data: $(form).serialize(),
                    success: function(data) {
                        layer.msg(data.msg, {time: 2000}, function() { //弹出信息提示框2秒自动关闭
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }
                });
            }
        });
    });
</script>

</body>

</html>
